﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace MM.Toolkit.Tester
{
    public partial class MainPage : UserControl
    {
        private MainPageModel model { get { return this.DataContext as MainPageModel; } }

        public MainPage()
        {
            InitializeComponent();

            this.Loaded += MainPage_Loaded;
            this.DataContext = App.MainPageModel;
        }

        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            // We set the SearchCompletedCommand binding here.
            // If the SearchBox was in a TemplatedControl, we can set this in the XAML by using a TemplateBinding
            // Reason : SearchCompletedCommand is a readonly (private setter) initiated inside the SearchBox
            BindingOperations.SetBinding(model, MainPageModel.SearchCompletedCommandProperty, new Binding("SearchCompletedCommand") { Source = this.CarSearchBox, Mode = BindingMode.OneWay });
        }
    }
}
